﻿#define  _CRT_SECURE_NO_WARNINGS 1
#include"Binary_Search_Tree.h"

void test_find()
{
	int arr[] = { 4,6,1,2,8,5,7,13,9,10 };
	BSTree<int> bst;
	for (auto k : arr)
	{
		bst.insert(k);
	}
	bst.Inorder();
	int val = 0;
	cout << "请输入您要查找的数字：";
	cin >> val;
	if (bst.Find(val))
	{
		cout << "找到了,该值是：" << val << endl;
	}
	else
	{
		cout << "未找到，可能二叉树中没有该值：" << val << endl;
	}
}

void test_erase()
{
	int arr[] = { 4,6,1,2,8,5,7,13,9,10 };
	BSTree<int> bst;
	for (auto k : arr)
	{
		bst.insert(k);
	}
	bst.Inorder();
	//int key=-1;
	//cout << "请输入要删除的数字：";
	//cin >> key;
	//if (bst.Erase(key))
	//{
	//	cout << "删除成功！" << endl;
	//}
	//else
	//{
	//	cout << "删除失败！" << endl;
	//}
	for (auto e : arr)
	{
		bst.Erase(e);
		bst.Inorder();
	}
}

int main()
{
	//test_find();
	test_erase();
	return 0;
}